package com.azier.kapacitor.script.node;

import com.azier.kapacitor.script.method.*;
import com.azier.kapacitor.script.node.nodebind.StatsNodeBind;

import java.util.ArrayList;

/**
* 1 * @Author: luoj
* 2 * @Date: 2019/11/8 11:27
* 3
*/

/**
Create an influxdb output node that will store the incoming data into InfluxDB.
**/
/**
创建一个influxdb输出节点，它将输入的数据存储到InfluxDB中。
**/
public class InfluxDBOutNode extends AbstractNode implements StatsNodeBind {
    private static final String name = "influxDBOut";

    public InfluxDBOutNode() {
        super(new ArrayList<>(),new ArrayList<>(),name);
    }

    /**
    Number of points to buffer when writing to InfluxDB. Default: 1000
    **/
    /**
    写入InfluxDB时要缓冲的点数。默认值：1000
    **/
    public InfluxDBOutNode buffer(long influxDBOut){
        Buffer buffer = new Buffer(influxDBOut);
        super.addMethod(buffer);
        return this;
    }
    /**
    The name of the InfluxDB instance to connect to. If empty the configured default will be used.
    **/
    /**
    要连接的InfluxDB实例的名称。如果为空，将使用配置的默认值。
    **/
    public InfluxDBOutNode cluster(String influxDBOut){
        Cluster cluster = new Cluster(influxDBOut);
        super.addMethod(cluster);
        return this;
    }
    /**
    Create indicates that both the database and retention policy will be created, when the task is started. If the retention policy name is empty then no retention policy will be specified and the default retention policy name will be created.
    **/
    /**
    创建表示在启动任务时将同时创建数据库和保留策略。如果保留策略名称为空，则不会指定任何保留策略，并且将创建默认保留策略名称。
    **/
    public InfluxDBOutNode create(){
        Create create = new Create();
        super.addMethod(create);
        return this;
    }
    /**
    The name of the database.
    **/
    /**
    数据库的名称。
    **/
    public InfluxDBOutNode database(String influxDBOut){
        Database database = new Database(influxDBOut);
        super.addMethod(database);
        return this;
    }
    /**
    Write points to InfluxDB after interval even if buffer is not full. Default: 10s
    **/
    /**
    即使缓冲区未满，也要在间隔后将点写入InfluxDB。默认值：10秒
    **/
    public InfluxDBOutNode flushInterval(long interval, String durationLiteral){
        FlushInterval flushInterval = new FlushInterval(interval, durationLiteral);
        super.addMethod(flushInterval);
        return this;
    }
    /**
    The name of the measurement.
    **/
    /**
    测量名称。
    **/
    public InfluxDBOutNode measurement(String influxDBOut){
        Measurement measurement = new Measurement(influxDBOut);
        super.addMethod(measurement);
        return this;
    }
    /**
    The precision to use when writing the data.
    **/
    /**
    写入数据时使用的精度。
    **/
    public InfluxDBOutNode precision(String influxDBOut){
        Precision precision = new Precision(influxDBOut);
        super.addMethod(precision);
        return this;
    }
    /**
    Suppress all error logging events from this node.
    **/
    /**
    禁止来自此节点的所有错误记录事件。
    **/
    public InfluxDBOutNode quiet(){
        Quiet quiet = new Quiet();
        super.addMethod(quiet);
        return this;
    }
    /**
    The name of the retention policy.
    **/
    /**
    保留策略的名称。
    **/
    public InfluxDBOutNode retentionPolicy(String influxDBOut){
        RetentionPolicy retentionPolicy = new RetentionPolicy(influxDBOut);
        super.addMethod(retentionPolicy);
        return this;
    }
    /**
    Add a static tag to all data points. Tag can be called more then once.
    **/
    /**
    将静态标签添加到所有数据点。标签可以再调用一次。
    **/
    public InfluxDBOutNode tag(String influxDBOut, String key){
        Tag tag = new Tag(influxDBOut, key);
        super.addMethod(tag);
        return this;
    }
    /**
    The write consistency to use when writing the data.
    **/
    /**
    写入数据时要使用的写入一致性。
    **/
    public InfluxDBOutNode writeConsistency(String influxDBOut){
        WriteConsistency writeConsistency = new WriteConsistency(influxDBOut);
        super.addMethod(writeConsistency);
        return this;
    }


/** ------------------------------------------------ **/
/** 链接节点  **/
/** ------------------------------------------------ **/

/** 未能写出的节点 **/

        //Deadman, 
        //Stats

}